From 9351cf98c98df199c074756ac0a47c791b93cf9b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Thu, 26 Sep 2024 15:14:34 -0500 Subject: [PATCH] Move sql_edit javascript into its own file --- src/pgwui_sql/static/sql_edit.js | 47 ++++++++++++++++++++++++++++ src/pgwui_sql/templates/sql_edit.mak | 31 +++--------------- 2 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 src/pgwui_sql/static/sql_edit.js diff --git a/src/pgwui_sql/static/sql_edit.js b/src/pgwui_sql/static/sql_edit.js new file mode 100644 index 0000000..7bb0eab --- /dev/null +++ b/src/pgwui_sql/static/sql_edit.js @@ -0,0 +1,47 @@ +/* Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/ + + This file is part of PGWUI_SQL. + + This program is free software: you can redistribute it and/or + modify it under the terms of the GNU Affero General Public License + as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public + License along with this program. If not, see + . + + Javascript for the sql edit window. + + Karl O. Pinc +*/ + +function show_search_path() { + fetch('${request.route_path("pgwui_sql_db_search_path")|n}') + .then((response) => { + if (!response.ok) { + window.alert('Problem obtaining the search_path'); + } + return response.text(); + }) + .then((search_path) => { + const sp_elemt = document.getElementById('search_path_id'); + sp_elemt.value = search_path; + }) + .catch((error) => { + window.alert('Problem showing the search_path: ' + error); + }) +}; +function toggle_sql_used(elem) { + sql_text = document.getElementById('sql_id'); + if (elem.checked) { + sql_text.style.backgroundColor = '#ececec'; + } else { + sql_text.style.backgroundColor = ''; + } +}; diff --git a/src/pgwui_sql/templates/sql_edit.mak b/src/pgwui_sql/templates/sql_edit.mak index e60c3a1..213e473 100644 --- a/src/pgwui_sql/templates/sql_edit.mak +++ b/src/pgwui_sql/templates/sql_edit.mak @@ -61,33 +61,6 @@ <%block name="top_hr"> - - <%def name="sql_row(tab_index)"> <%self.lib:td_label for_id="search_path_id"> @@ -283,3 +256,7 @@ % else:

Not logged in. Close this window and re-open it after logging in.

% endif + + -- 2.34.1